package com.ibp.controller;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ibp.entity.IbpEventLogData;
import com.ibp.response.DataResponse;
import com.ibp.service.StatisticalAnalysisService;

@Controller
@RequestMapping("statisticalAnalysis")
public class StatisticalAnalysisController {
    private static Logger logger = LoggerFactory.getLogger(StatisticalAnalysisController.class);
	
    @Autowired 
    StatisticalAnalysisService statisticalAnalysisServiceImpl;
    
    
    /***
     * 跳转到交易量统计分析页面
     * @return
     */
	@RequestMapping("/tradeVolumeAnalysis")
	public String toTradeVolumeAnalysis(){
		logger.info("跳转交易量统计分析页面-->trade_volume_analysis.jsp");
		return "ibp/trade_volume_analysis";
	}
	
    /***
     * 获取交易统计数据
     * @return
     */
	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping("/getData")
	public DataResponse<Map<String, Object>> getData(IbpEventLogData elog){
		logger.info("交易统计数据加载："+elog.toString());
		DataResponse<Map<String,Object>> response = new DataResponse<Map<String,Object>>();
		response.setData(statisticalAnalysisServiceImpl.getData(elog));
		return response ;
	}
	
	
    /***
     * 获取交易统计数据(两个曲线图)
     * @return
     */
	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping("/getLineData")
	public DataResponse<Map<String, Object>> getLineData(IbpEventLogData elog){
		logger.info("交易统计数据加载[曲线图]："+elog.toString());
		DataResponse<Map<String,Object>> response = new DataResponse<Map<String,Object>>();
		response.setData(statisticalAnalysisServiceImpl.getLineData(elog));
		return response ;
	}
	
	
    /***
     * 获取交易统计数据(两个饼图)
     * @return
     */
	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping("/getPieData")
	public DataResponse<Map<String, Object>> getPieData(IbpEventLogData elog){
		logger.info("交易统计数据加载[饼图]："+elog.toString());
		DataResponse<Map<String,Object>> response = new DataResponse<Map<String,Object>>();
		response.setData(statisticalAnalysisServiceImpl.getPieData(elog));
		return response ;
	}
	
}
